1、两个有序数组的中位数
思想：就是利用二分思想，依次比较每个数组对应下标的值
class Solution {
public:
    int _findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2,int k)
    {
        int m=nums1.size();
        int n=nums2.size();
        int index1=0;
        int index2=0;
        while(1)
        {
            if(index1==m)
                return nums2[index2+k-1];
            else if(index2==n)
                return nums1[index1+k-1];
            if(k==1)
                return min(nums1[index1],nums2[index2]);
            int newindex1=min(index1+k/2-1,m-1);
            int newindex2=min(index2+k/2-1,n-1);
            int x1=nums1[newindex1];
            int x2=nums2[newindex2];
            if(x1<=x2)
            {
                k-=newindex1-index1+1;
                index1=newindex1+1;
            }
            else
            {
                k-=newindex2-index2+1;
                index2=newindex2+1;
            }

        }
        return 0;
    }
    double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
        int size=nums1.size()+nums2.size();
        if(size%2)
            return (double)_findMedianSortedArrays(nums1,nums2,(size+1)/2);
        else
            return (double)(_findMedianSortedArrays(nums1,nums2,size/2)+_findMedianSortedArrays(nums1,nums2,size/2+1))/2;
    }
};